<template>
	<view>
		<view class="padding text-bold text-lg">
			提现到
		</view>
		
		<view class="block">
			<view class="cu-form-group">
				<input placeholder="请输入持卡人姓名" disabled v-model="form.name" name="input"></input>
			</view>
			<view class="cu-form-group">
				<input placeholder="请输入持卡人卡号" disabled v-model="form.bank_name" name="input"></input>
			</view>
			<view class="cu-form-group">
				<input placeholder="请输入持卡人卡号" disabled v-model="form.card_no" name="input"></input>
			</view>
		</view>
		
		<view class="margin-top padding text-bold text-lg">
			提现金额
		</view>
		
		<view class="block">
			<view class="cu-form-group">
				<input placeholder="请输入金额" v-model="draw_money" type="digit" name="input"></input>
			</view>
		</view>
		<view class="margin-top padding-lr text-sm text-right text-gray">钱包余额：{{money}}</view>
		<view class="padding-lr text-sm text-right text-gray">费率：{{rate}}%</view>
		
		
		<view class="add-btn" @click="getMoney">提交</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				flag: 1,
				num: '验证码',
				money: '',
				rate: '',
				draw_money: '',
				form: {
					card_no: '',
					name: '',
					bank_name: '',
					code: ''
				}
			}
		},
		onLoad() {
			this.getBank();
		},
		methods: {
			getBank() {
				uni.showLoading({
					mask: true
				})
				this.$u.get('/finance/draw/info').then(res => {
					let data = res.data.result.bank
					if (data) {
						this.form.name = data.name
						this.form.bank_name = data.bank_name
						this.form.card_no = data.card_no
						
						this.money = res.data.result.userfund.wallet
						this.rate = res.data.result.draw_fee
					}
					
					uni.hideLoading();
				})
			},
			getMoney() {
				this.$u.post('/finance/draw', {
					draw_money: this.draw_money
				}).then(res => {
					this.getBank();
					this.$msg('操作成功')
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}
	.block .cu-form-group:nth-last-of-type(1) {
		border-bottom: 1upx solid #eee;
	}

	.add-btn {
		width: 100%;
		height: 100rpx;
		background: #1f1f1f;
		color: white;
		line-height: 100rpx;
		text-align: center;
		font-size: 32rpx;
		letter-spacing: 2rpx;
		position: fixed;
		bottom: 0;
	}
</style>
